package com.pray.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.pray.entity.po.Role;
import com.pray.service.RoleService;
import com.pray.utils.Result;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * UserController
 *
 * @author 春江花朝秋月夜
 * @since 2023/11/12 14:57
 */
@RestController
@RequestMapping("/role")
public class RoleController {
    @Resource
    RoleService roleService;
    @GetMapping()
    public Result<List<Role>> getAll() throws JsonProcessingException {
        return  Result.ok(roleService.listRole(10,20));
    }
    @PostMapping("/update")
    public Result<String> updatePageInfo(@RequestBody Role role) throws JsonProcessingException, InterruptedException {
        //返回插入的更新数据
        return Result.ok(roleService.updatePageWithMutex(role));
    }
}
